<% layout('/layouts/default.html', {title: 'quartz定时任务表管理', libs: ['validate']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text(quartzJob.isNewRecord ? '新增quartz定时任务表' : '编辑quartz定时任务表')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${quartzJob}" action="${ctx}/quartz/quartzJob/save" method="post" class="form-horizontal">
		<div class="box-body">
			<div class="form-unit">${text('基本信息')}</div>
			<#form:hidden path="id"/>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('任务类名')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="jobClassName" maxlength="255" class="form-control"/>
						</div>
					</div>
				</div>
				<div class="col-xs-12">
					<div class="form-group">
						<label class="control-label col-sm-2" title="">
							<span class="required hide">*</span> ${text('描述')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-10">
							<#form:input path="description" maxlength="255" class="form-control"/>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('cron表达式')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="cronExpression" maxlength="255" class="form-control"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('参数')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="parameter" maxlength="255" class="form-control"/>
						</div>
					</div>
				</div>
			</div>
			<div class="row" style="display: none">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('修改时间')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="updateTime" readonly="true" maxlength="20" class="form-control Wdate"
							dataFormat="datetime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:true});"/>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="box-footer">
			<div class="row">
				<div class="col-sm-offset-2 col-sm-10">
					<% if (hasPermi('quartz:quartzJob:edit')){ %>
					<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
					<% } %>
					<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
				</div>
			</div>
		</div>
	</#form:form>
</div>
</div>
<% } %>
<script>
	$("#inputForm").validate({
		submitHandler: function(form){
			js.ajaxSubmitForm($(form), function(data){
				js.showMessage(data.message);
				if(data.result == Global.TRUE){
					js.closeCurrentTabPage(function(contentWindow){
						contentWindow.page();
					});
				}
			}, "json");
		}
	});

	$(function () {
		bindCron("cronExpression");
	})

	/**
	 * 绑定Cron点击事件
	 */
	function bindCron(id) {
		$("#" + id).on("click", function (e) {
			openCronFrame(id);
		})
	}

	/**
	 *  Cron执行表达式
	 * @param id 写入表达式的组件id
	 */
	function openCronFrame(id) {
		layer.open({
			title: "Cron执行表达式",
			type: 1,
			id: "cronFrameLayer",
			btn: ['确定', '取消'],
			area: ['660px', '530px'],
			//不固定
			fixed: false,
			maxmin: true,
			//点击遮罩层关闭
			shadeClose: true,
			content: "<iframe id='cronFrame' src='${ctxStatic}/cron-quartz/index.html?ctx=/js/a' " +
					"style=\"width:660px;height:530px;border:0\"></iframe>",
			yes: function (index, layero) {
				var body = layer.getChildFrame('body', index);
				var cron = body.find("#cron").val();
				if (cron != null && cron != undefined && cron != "") {
					$("#" + id).val(cron);
				}
				layer.close(index); //如果设定了yes回调，需进行手工关闭
			}
		});
	}
</script>
